]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
animation: Save file and dimensions in properties
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 24 Dec 2023 10:11:14 +0000 (11:11 +0100)
committerMarge Bot <marge-bot@gnome.org>
Wed, 27 Dec 2023 10:10:35 +0000 (10:10 +0000)
The properties passed to the constructor are currently used
directly in anonymous functions. Store them in properties
instead, so they become accessible outside the constructor,
including for changing them.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3080>

js/ui/animation.js

index c300c841fa5fbc6c0fcaac29e04f67fc4ccbaa69..85b4d5d732d9261074b3f59c01a80621e283856a 100644 (file)
@@ -21,14 +21,20 @@ class Animation extends St.Bin {
             style: `width: ${width}px; height: ${height}px;`,
         });
 
+        this._file = file;
+        this._width = width;
+        this._height = height;
+
         this.connect('destroy', this._onDestroy.bind(this));
         this.connect('resource-scale-changed',
-            this._loadFile.bind(this, file, width, height));
+            () => this._loadFile());
 
         themeContext.connectObject('notify::scale-factor',
             () => {
-                this._loadFile(file, width, height);
-                this.set_size(width * themeContext.scale_factor, height * themeContext.scale_factor);
+                this._loadFile();
+                this.set_size(
+                    this._width * themeContext.scale_factor,
+                    this._height * themeContext.scale_factor);
             }, this);
 
         this._speed = speed;
@@ -38,7 +44,7 @@ class Animation extends St.Bin {
         this._timeoutId = 0;
         this._frame = 0;
 
-        this._loadFile(file, width, height);
+        this._loadFile();
     }
 
     play() {
@@ -62,7 +68,7 @@ class Animation extends St.Bin {
         this._isPlaying = false;
     }
 
-    _loadFile(file, width, height) {
+    _loadFile() {
         const resourceScale = this.get_resource_scale();
         let wasPlaying = this._isPlaying;
 
@@ -74,7 +80,8 @@ class Animation extends St.Bin {
 
         let textureCache = St.TextureCache.get_default();
         let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
-        this._animations = textureCache.load_sliced_image(file, width, height,
+        this._animations = textureCache.load_sliced_image(this._file,
+            this._width, this._height,
             scaleFactor, resourceScale,
             () => this._loadFinished());
         this._animations.set({